package game.editer.ui;

import echo.Body;
import hx.events.MouseEvent;

/**
 * 碰撞绘制编辑支持
 */
class CollisionInput extends BaseAttributeInput {
	var button = new Button();

	override function onInit() {
		super.onInit();
		button.text = "删除";
		button.width = 110;
		button.addEventListener(MouseEvent.CLICK, (e) -> {
			this.value = null;
			onAttributeChange(this);
		});
		this.addChild(button);
	}

	override function set_value(value:Dynamic):Dynamic {
		var c:Body = value;
		button.alpha = (c != null && c.shapes.length > 0) ? 1 : 0.5;
		button.mouseEnabled = (c != null && c.shapes.length > 0);
		return super.set_value(value);
	}
}
